package com.lvmama.rhino.pojo.comment.Enum;

/**
 * @Author:caoyong
 * @Description: 评论天数
 * @Date：2017/9/20
 */
public enum CommentDaysEnum {
    YESTERDAY(1,"昨天"),
    THREE_DAY(3,"三天内"),
    WEEK(7,"近七天"),
    HALF_A_MONTH(15,"半月内"),
    MONTH(31, "一月内"),
    THREE_MONTH(92,"三个月内"),
    YEAR(365, "全部");//目前一年的数据用来表示全部

    CommentDaysEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    private Integer code;
    private String name;

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    /**
     * 根据code获取枚举
     * @param code
     * @return
     */
    public static CommentDaysEnum getEnum(Integer code){
        for(CommentDaysEnum en : CommentDaysEnum.values()){
            if(en.getCode().equals(code)){
                return en;
            }
        }
        return null;
    }
}
